Skip to content

Use published SDK version instead of local replace directives#1067

Merged
renuka-fernando merged 6 commits intowso2:mainfrom
renuka-fernando:publised-sdk
Feb 13, 2026
Merged

Use published SDK version instead of local replace directives#1067
renuka-fernando merged 6 commits intowso2:mainfrom
renuka-fernando:publised-sdk

Conversation

@renuka-fernando
Copy link
Contributor

@renuka-fernando renuka-fernando commented Feb 11, 2026

Summary

Fix #1066

  • Replace local SDK replace directives with published version v0.3.9 in gateway go.mod files
  • Add separate CI workflow (sdk-integration-test.yml) to validate SDK changes against gateway integration tests

Problem

Gateway components used replace github.com/wso2/api-platform/sdk => ../../sdk to always build against local SDK source. Since the SDK is a user-facing published module with external consumers (policy authors), this caused non-reproducible builds and masked potential interface drift between the gateway runtime and published SDK versions.

Changes

go.mod (3 files):

  • gateway/gateway-runtime/policy-engine/go.mod — removed SDK replace directive
  • gateway/gateway-builder/go.mod — removed SDK replace, updated v0.0.0v0.3.9
  • gateway/gateway-controller/go.mod — removed SDK replace, updated v0.0.0v0.3.9
  • common module replace directives kept as-is (internal, unpublished module)

CI (1 new file):

  • .github/workflows/sdk-integration-test.yml — triggers on sdk/** changes, injects go mod edit -replace to test local SDK against gateway integration tests

No changes to Dockerfiles or Makefiles — SDK source continues to be copied into Docker builds via --build-context sdk. During normal builds Go downloads the published version from module proxy; during SDK CI testing the injected replace directive makes Go use the local copy.

Summary by CodeRabbit

  • Chores
    • CI: Expanded integration-test PR triggers to include shared/common code and added a new SDK integration workflow that runs Go/Docker builds, integration tests, and diagnostic log collection.
    • Dependencies: Upgraded the SDK and several libraries across components.
    • Build: Removed local module replacement overrides to standardize build behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Removes local SDK replace directives from gateway modules and upgrades them to published SDK v0.3.14; adds common/** to the gateway CI path filters and introduces a new sdk-integration-test.yml workflow that can inject local SDK replacements and run gateway integration tests.

Changes

Cohort / File(s) Summary
CI Workflows
.github/workflows/gateway-integration-test.yml, .github/workflows/sdk-integration-test.yml
Adds common/** to gateway workflow PR path filters; adds a new SDK integration workflow that sets up Go 1.25 and Docker Buildx, applies go mod edit -replace for local SDK testing, builds coverage-instrumented gateway images and mock servers, runs integration tests, and collects diagnostics on failure.
Gateway go.mod updates
gateway/gateway-builder/go.mod, gateway/gateway-controller/go.mod, gateway/gateway-runtime/policy-engine/go.mod
Removes local replace for github.com/wso2/api-platform/sdk, updates gateway modules to require published SDK v0.3.14 (or later), retains replace for local common where applicable, and removes prior Docker-build replace blocks.
SDK module changes
sdk/go.mod
Multiple dependency upgrades and transitive updates (milvus, redis, etcd groups, google/btree, golang-jwt additions), removal of an old jwt indirect, and various indirect dependency version bumps.
Common & platform modules
common/go.mod, platform-api/src/go.mod
Bumps github.com/golang-jwt/jwt/v5 from v5.3.0 → v5.3.1.
Sample & system policy modules
gateway/sample-policies/uppercase-body/go.mod, gateway/system-policies/analytics/go.mod
Updates SDK requirement to align with v0.3.14 and removes some indirect dependency entries.
Other manifest edits
gateway/gateway-controller/go.mod (additional indirect edits)
Various indirect dependency adjustments (cel.dev/expr, golang-jwt/jwt/v5) and removal of several unused indirects and local Docker-build replace block.

Sequence Diagram(s)

sequenceDiagram
    participant GH as GitHub Actions
    participant Repo as Repository
    participant Go as Go toolchain (1.25)
    participant Docker as Docker Buildx
    participant Gateway as Gateway build/test
    participant Mocks as Mock server images

    GH->>Repo: trigger (gateway/**, common/**) or (sdk/** / workflow_dispatch)
    GH->>Repo: checkout
    GH->>Go: setup Go 1.25
    GH->>Docker: setup Buildx
    alt SDK workflow (sdk/**)
        GH->>Repo: run `go mod edit -replace` to point gateway modules at local SDK
    end
    GH->>Gateway: build gateway images (make build-coverage / build-local)
    GH->>Mocks: build mock server images
    GH->>Gateway: run integration tests (make test-integration)
    Gateway-->>GH: test results
    alt failure
        GH->>Docker: docker ps / docker logs
        GH->>Repo: dump gateway/it/logs if present
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Update main #1015: Modifies the same gateway and SDK go.mod files and replace directives; closely related to switching from local SDK replaces to published SDK usage.

Suggested reviewers

  • Thushani-Jayasekera

Poem

🐰 I nudged the SDK from local to sky,
Workflows hop, builds leap high,
Replaces trimmed, CI paths widened too,
Tests and mocks line up in view,
A carrot for green checks — a tiny hop, woohoo! 🥕

🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (21 files):

⚔️ .github/workflows/gateway-integration-test.yml (content)
⚔️ common/go.mod (content)
⚔️ common/go.sum (content)
⚔️ gateway/gateway-builder/go.mod (content)
⚔️ gateway/gateway-builder/go.sum (content)
⚔️ gateway/gateway-controller/go.mod (content)
⚔️ gateway/gateway-controller/go.sum (content)
⚔️ gateway/gateway-runtime/policy-engine/go.mod (content)
⚔️ gateway/gateway-runtime/policy-engine/go.sum (content)
⚔️ gateway/sample-policies/uppercase-body/go.mod (content)
⚔️ gateway/sample-policies/uppercase-body/go.sum (content)
⚔️ gateway/system-policies/analytics/go.mod (content)
⚔️ gateway/system-policies/analytics/go.sum (content)
⚔️ go.work (content)
⚔️ go.work.sum (content)
⚔️ platform-api/src/go.mod (content)
⚔️ platform-api/src/go.sum (content)
⚔️ platform-api/src/internal/server/server.go (content)
⚔️ platform-api/src/resources/openapi.yaml (content)
⚔️ sdk/go.mod (content)
⚔️ sdk/go.sum (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: moving from local SDK replace directives to published versions.
Description check ✅ Passed The PR description covers the purpose, problem, changes, and approach with sufficient detail, though some template sections like security checks and test environment are not explicitly filled.
Linked Issues check ✅ Passed All primary coding objectives from issue #1066 are met: SDK replace directives removed from gateway components, published version used, common module replace kept, and SDK CI workflow added.
Out of Scope Changes check ✅ Passed All changes directly address issue #1066: go.mod updates, SDK workflow, and dependency updates are within scope; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/sdk-integration-test.yml:
- Around line 27-36: The workflow step that injects the local SDK via go mod
edit -replace into the modules (gateway/gateway-runtime/policy-engine,
gateway-builder, gateway-controller) is missing go mod tidy, which can leave
go.sum inconsistent; after each go mod edit -replace invocation run go mod tidy
in the same module to update go.sum and pull correct transitive deps, and make
the step more robust by using absolute paths based on $GITHUB_WORKSPACE instead
of chained cd commands so each module (policy-engine, gateway-builder,
gateway-controller) is edited and tidied reliably.

Comment on lines +27 to +36
- name: Inject local SDK into gateway modules
run: |
cd gateway/gateway-runtime/policy-engine
go mod edit -replace github.com/wso2/api-platform/sdk=../../../sdk

cd ../../gateway-builder
go mod edit -replace github.com/wso2/api-platform/sdk=../../sdk

cd ../gateway-controller
go mod edit -replace github.com/wso2/api-platform/sdk=../../sdk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Missing go mod tidy after injecting replace directives.

After go mod edit -replace, the go.sum files won't reflect the local SDK's transitive dependencies. If the local SDK differs from v0.3.9 in its dependency graph, subsequent go build or go test may fail or fetch unexpected versions. Run go mod tidy in each module after editing.

Also, the chained cd navigation is fragile — consider using absolute paths from $GITHUB_WORKSPACE for clarity.

Proposed fix
       - name: Inject local SDK into gateway modules
         run: |
-          cd gateway/gateway-runtime/policy-engine
-          go mod edit -replace github.com/wso2/api-platform/sdk=../../../sdk
+          cd $GITHUB_WORKSPACE/gateway/gateway-runtime/policy-engine
+          go mod edit -replace github.com/wso2/api-platform/sdk=../../../sdk
+          go mod tidy
 
-          cd ../../gateway-builder
-          go mod edit -replace github.com/wso2/api-platform/sdk=../../sdk
+          cd $GITHUB_WORKSPACE/gateway/gateway-builder
+          go mod edit -replace github.com/wso2/api-platform/sdk=../../sdk
+          go mod tidy
 
-          cd ../gateway-controller
-          go mod edit -replace github.com/wso2/api-platform/sdk=../../sdk
+          cd $GITHUB_WORKSPACE/gateway/gateway-controller
+          go mod edit -replace github.com/wso2/api-platform/sdk=../../sdk
+          go mod tidy
🤖 Prompt for AI Agents
In @.github/workflows/sdk-integration-test.yml around lines 27 - 36, The
workflow step that injects the local SDK via go mod edit -replace into the
modules (gateway/gateway-runtime/policy-engine, gateway-builder,
gateway-controller) is missing go mod tidy, which can leave go.sum inconsistent;
after each go mod edit -replace invocation run go mod tidy in the same module to
update go.sum and pull correct transitive deps, and make the step more robust by
using absolute paths based on $GITHUB_WORKSPACE instead of chained cd commands
so each module (policy-engine, gateway-builder, gateway-controller) is edited
and tidied reliably.

@renuka-fernando renuka-fernando force-pushed the publised-sdk branch 4 times, most recently from cad4325 to 180495e Compare February 13, 2026 06:52
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
gateway/gateway-runtime/policy-engine/go.mod (1)

18-18: ⚠️ Potential issue | 🟠 Major

SDK version inconsistency across gateway modules.

The policy-engine remains on SDK v0.3.9, while gateway-controller and sample-policies have been upgraded to v0.3.14. This creates version skew across gateway components that could lead to incompatibility issues.

Please align all gateway modules to use the same SDK version (v0.3.14) to ensure consistent behavior and API compatibility.

🔄 Proposed fix to align SDK version
-	github.com/wso2/api-platform/sdk v0.3.9
+	github.com/wso2/api-platform/sdk v0.3.14

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@sdk/go.mod`:
- Around line 88-94: The go.mod bump to etcd v3.5.23 may require API
changes—search the codebase for any use of the etcd resolver types (e.g.,
resolver.State, resolver.State.Addresses, clientv3 or grpc resolver
integrations) and update usages that expect resolver.State.Addresses to the new
shape (resolver.State.Endpoint.Addresses) or adapt to the new Endpoint wrapper;
ensure any code referencing clientv3 resolver/state APIs in functions/methods
interacting with etcd clients is updated accordingly, run unit/integration tests
against v3.5.23 (including any code that does snapshot/defrag or lease renewal),
and consult the etcd 3.5 upgrade guide to apply any other required migration
steps before merging.

Comment on lines +88 to +94
go.etcd.io/etcd/api/v3 v3.5.23 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.23 // indirect
go.etcd.io/etcd/client/v2 v2.305.23 // indirect
go.etcd.io/etcd/client/v3 v3.5.23 // indirect
go.etcd.io/etcd/pkg/v3 v3.5.23 // indirect
go.etcd.io/etcd/raft/v3 v3.5.23 // indirect
go.etcd.io/etcd/server/v3 v3.5.23 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Find the go.mod file in the repository
find . -name "go.mod" -type f | head -20

Repository: wso2/api-platform

Length of output: 743


🏁 Script executed:

# Examine lines 88-94 of sdk/go.mod
sed -n '80,100p' ./sdk/go.mod

Repository: wso2/api-platform

Length of output: 1238


🏁 Script executed:

# Check git history for this file to see previous versions
cd ./sdk && git log -p --follow -S "go.etcd.io/etcd/api/v3" -- go.mod | head -100

Repository: wso2/api-platform

Length of output: 43


🏁 Script executed:

# Verify etcd package versions exist using Go module proxy
echo "=== Checking go.etcd.io/etcd/api/v3 v3.5.23 ==="
curl -s "https://proxy.golang.org/go.etcd.io/etcd/api/v3/@v/v3.5.23.info" | head -20

echo -e "\n=== Checking go.etcd.io/etcd/client/v3 v3.5.23 ==="
curl -s "https://proxy.golang.org/go.etcd.io/etcd/client/v3/@v/v3.5.23.info" | head -20

echo -e "\n=== Listing available etcd/api/v3 versions around v3.5.23 ==="
curl -s "https://proxy.golang.org/go.etcd.io/etcd/api/v3/@v/list" | grep "v3.5" | tail -20

Repository: wso2/api-platform

Length of output: 818


🏁 Script executed:

# Check for go.mod.orig or similar to see previous versions
ls -la ./sdk/go.mod* 2>/dev/null || echo "No backup found"

# Also check if there's a go.sum file we can examine
wc -l ./sdk/go.mod ./sdk/go.sum 2>/dev/null

# Get info on a few earlier versions to understand the jump
echo -e "\n=== Checking v3.5.5 ==="
curl -s "https://proxy.golang.org/go.etcd.io/etcd/api/v3/@v/v3.5.5.info"

echo -e "\n=== Checking v3.5.22 and v3.5.24 ==="
curl -s "https://proxy.golang.org/go.etcd.io/etcd/api/v3/@v/v3.5.22.info"
curl -s "https://proxy.golang.org/go.etcd.io/etcd/api/v3/@v/v3.5.24.info"

Repository: wso2/api-platform

Length of output: 861


🏁 Script executed:

# Check for security advisories and important changes
echo "=== Checking etcd releases page for security info ==="
curl -s "https://api.github.com/repos/etcd-io/etcd/releases?per_page=30" | \
  jq -r '.[] | select(.tag_name | contains("v3.5")) | "\(.tag_name) - \(.published_at) - Draft: \(.draft)"' | \
  head -30

# Also search for any known CVEs affecting etcd 3.5
echo -e "\n=== Searching for etcd security advisories ==="
curl -s "https://api.github.com/repos/etcd-io/etcd/security/advisories" 2>/dev/null | jq '.[].ghsa_id' 2>/dev/null || echo "Security advisories API may require authentication"

Repository: wso2/api-platform

Length of output: 673


🏁 Script executed:

# Check the actual release notes for v3.5.23 to see if there are breaking changes
echo "=== Fetching v3.5.23 release details ==="
curl -s "https://api.github.com/repos/etcd-io/etcd/releases/tags/v3.5.23" | \
  jq -r '.body' | head -100

# Also check if there were any significant fixes between v3.5.5 and v3.5.23
echo -e "\n=== Checking changelog summary ==="
curl -s "https://raw.githubusercontent.com/etcd-io/etcd/v3.5.23/CHANGELOG/v3.5.md" 2>/dev/null | head -200 || echo "Changelog not directly accessible"

Repository: wso2/api-platform

Length of output: 3888


🏁 Script executed:

# Try accessing the main changelog file
echo "=== Checking main changelog ==="
curl -s "https://raw.githubusercontent.com/etcd-io/etcd/main/CHANGELOG/CHANGELOG-3.5.md" 2>/dev/null | head -300

# Also check git tags to see what versions exist
echo -e "\n=== Verifying patch versions between v3.5.5 and v3.5.23 ==="
curl -s "https://api.github.com/repos/etcd-io/etcd/git/refs/tags" | \
  jq -r '.[] | select(.ref | contains("v3.5")) | .ref' | sort -V | grep -E "v3\.5\.(5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23)" | tail -20

Repository: wso2/api-platform

Length of output: 14476


Verify compatibility with etcd v3.5.23 breaking changes and review the upgrade guide.

The etcd packages are being updated from v3.5.5 to v3.5.23 (18 patch versions over ~3 years). While the version exists and includes important fixes, v3.5.22 introduced a breaking change: the clientv3 package replaced resolver.State.Addresses with resolver.State.Endpoint.Addresses. Review the code for any direct usage of this API and consult the etcd upgrade guide before merging. Additionally, v3.5.23 fixes critical issues including potential data corruption during concurrent snapshot and defragmentation operations, and lease renewal failures.

🤖 Prompt for AI Agents
In `@sdk/go.mod` around lines 88 - 94, The go.mod bump to etcd v3.5.23 may require
API changes—search the codebase for any use of the etcd resolver types (e.g.,
resolver.State, resolver.State.Addresses, clientv3 or grpc resolver
integrations) and update usages that expect resolver.State.Addresses to the new
shape (resolver.State.Endpoint.Addresses) or adapt to the new Endpoint wrapper;
ensure any code referencing clientv3 resolver/state APIs in functions/methods
interacting with etcd clients is updated accordingly, run unit/integration tests
against v3.5.23 (including any code that does snapshot/defrag or lease renewal),
and consult the etcd 3.5 upgrade guide to apply any other required migration
steps before merging.

The SDK is a user-facing published module, so gateway components should depend on a specific published version (v0.3.9) rather than using local replace directives. This ensures gateway builds use the same SDK version that external policy authors depend on, providing reproducible builds and clear compatibility contracts.
 - Remove SDK replace directives from policy-engine, gateway-builder, and gateway-controller go.mod files
 - Update gateway-builder and gateway-controller SDK dependency from v0.0.0 to published v0.3.9
 - Keep common module replace directives (internal, unpublished module)
 - Add separate sdk-integration-test workflow that injects local SDK via go mod edit -replace to validate SDK changes against gateway integration tests
@renuka-fernando renuka-fernando merged commit 4ae4e4f into wso2:main Feb 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use published sdk go module instead of using local latest sdk in gateway build

3 participants